//
//  DHSubscribeManager_Cell.m
//  Dresshere
//
//  Created by ZhangPeng on 2018/6/14.
//  Copyright © 2018年 张朋. All rights reserved.
//

#import "DHSubscribeManager_Cell.h"
#import "DHSubscribe_CompensationController.h"

@interface DHSubscribeManager_Cell()

@property (strong, nonatomic) NSDictionary *dic;

@end

@implementation DHSubscribeManager_Cell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.redButton.layer.cornerRadius = self.redButton.height / 2;
    
    WeakSelf(weakSelf)
    [self.redButton bk_addEventHandler:^(id sender) {
        DHSubscribe_CompensationController *vc = [[DHSubscribe_CompensationController alloc] init];
        vc.size_id = [weakSelf.dic objectForKey:@"size_id"];
        [weakSelf.viewController.navigationController pushViewController:vc animated:YES];
    } forControlEvents:UIControlEventTouchUpInside];
}

- (void)updateCell:(NSDictionary *)dic{
    self.dic = dic;
    [self.imgView dh_setImageURLString:[dic objectForKey:@"image"]];
    self.nameLabel.text = [dic objectForKey:@"name"];
    self.priceLabel.text = [NSString stringWithFormat:@"￥%.2f",[[dic objectForKey:@"price"] floatValue]];
    self.numberLabel.text = [NSString stringWithFormat:@"商品编号:%@",[dic objectForKey:@"serial_number"]? : @""];
    self.sizeLabel.text = [NSString stringWithFormat:@"尺码:%@",[dic objectForKey:@"size"]];
    self.statusLabel.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"status"]];
    self.dayLabel.text = [NSString stringWithFormat:@"已订阅%@天",@"0"];
    
    NSDictionary *compensate = [dic objectForKey:@"compensate"];
    if ([compensate objectForKey:@"compensate_id"]) {
        self.redButton.hidden = NO;
    }else{
        self.redButton.hidden = YES;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
